<template>
  <div class="header_go_back" :class="{'center_layout': center}">
    <div class="header_back inline_black" @click="handleGoBack">
      <i class="iconfont icon-fanhui" v-if="backType === 'back'"></i>
      <i class="iconfont icon-shanchu" v-if="backType === 'delete'"></i>
    </div>
    <div class="header_title inline_black">
      {{ title }}
      <slot name="title"></slot>
    </div>
    <div class="header_button inline_black" @click="handleOk">
      {{ text }}
      <slot name="text"></slot>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  props: {
    title: {
      type: String,
    },
    text: {
      type: String
    },
    center: {
      type: Boolean,
      default: false
    },
    backType: {
      type: String,
      default: 'back'
    }
  },
  setup(props, context) {
    const handleGoBack = () => {
      context.emit('back', '')
    }
    const handleOk = () => {
      context.emit('ok', '')
    }
    return {
      handleGoBack,
      handleOk
    }
  }
})
</script>

<style scoped>
  .inline_black {
    display: inline-block;
  }
  .header_go_back {
    padding: 0 20px;
    height: 60px;
    line-height: 60px;
    font-size: 20px;
    font-family: 'MainFont';
    text-align: start;
    border-bottom: #e8e8e6 1px solid;
    box-shadow: #e8e8e6 1px 1px 2px;
  }
  .center_layout {
    display: flex;
    justify-content: space-between;
  }
  .header_title {
    padding: 0 10px;
  }
  .header_button {
    float: right;
    font-size: 18px;
    color: #646464;
  }
</style>